//
// FrmProductDetails.cs
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (C) 2003 Microsoft Corporation.  All Rights Reserved.
//
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Data;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

using System.Diagnostics;

namespace Shraga.Client
{

	/// <summary>
	/// Passed a reference to a DataSet containing information from the Fabrikam Product Catalog,
	/// and a ProductID, we will display selected information on this form.  
	/// No databinding is used, although this would be an alternative.
	/// </summary>
	public class FrmProductDetail : System.Windows.Forms.Form
	{

		private int productID;

		private System.Data.DataView dataView1;
		private System.Windows.Forms.TextBox txtProductID;
		private System.Windows.Forms.Label lblProductID;
		private System.Windows.Forms.Label lblRangeName;
		private System.Windows.Forms.TextBox txtRangeName;
		private System.Windows.Forms.Label lblDescription;
		private System.Windows.Forms.TextBox txtDescription;
		private System.Windows.Forms.Label lblType;
		private System.Windows.Forms.Label lblCost;
		private System.Windows.Forms.TextBox txtCost;
		private System.Windows.Forms.Label lblWholeSale;
		private System.Windows.Forms.TextBox txtWholeSale;
		private System.Windows.Forms.Label lblRetail;
		private System.Windows.Forms.TextBox txtRetail;
		private System.Windows.Forms.Label LaborHours;
		private System.Windows.Forms.TextBox txtLaborHours;
		private System.Windows.Forms.TextBox txtType;
		private System.Windows.Forms.Label lblNoProducts;
		private System.Timers.Timer timer1;
		private System.Windows.Forms.PictureBox picShape;



		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		private FrmProductDetail()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			lblNoProducts.Visible = false;
			
		}

		/// <summary>
		/// Custom constructor for FrmProductDetailClass.
		/// Pass reference to dataset, product ID key, and Metafile from Shape.
		/// Display details for this product.
		/// </summary>
		/// <param name="fabrikamDS"></param>
		/// <param name="productID"></param>
		/// <param name="mf"></param>
		public FrmProductDetail( DataSet fabrikamDS, int productID, Metafile mf): 
			this( fabrikamDS, productID)
		{
			try
			{
				this.picShape.Image = mf;
			}
			catch( Exception exp)
			{
				throw exp;
			}
		}

		/// <summary>
		/// Custom constructor for FrmProductDetailClass.
		/// Pass a reference to the dataset and product id key, display details.
		/// </summary>
		/// <param name="fabrikamDS">Dataset used to hold Product Catalog</param>
		/// <param name="productID">Product ID key</param>
		public FrmProductDetail( DataSet fabrikamDS, int productID) : this()
		{
			try
			{
				this.productID = productID;

				dataView1 = new DataView(fabrikamDS.Tables[0]);

				dataView1.RowFilter = "ProductID = " + productID.ToString();
			
				//always display ProductID
				txtProductID.Text = productID.ToString();

				if (dataView1.Count > 0 )
				{
	
					//txtProductID.Text	= dataView1[0]["ProductID"].ToString();
					txtRangeName.Text	= dataView1[0]["RangeName"].ToString();
					txtDescription.Text = dataView1[0]["ProductDescription"].ToString();
					txtType.Text		= dataView1[0]["TypeDescription"].ToString();
					txtCost.Text		= String.Format("{0:c}", dataView1[0]["CostPrice"]);
					txtWholeSale.Text	= String.Format("{0:c}", dataView1[0]["WholesalePrice"]);
					txtRetail.Text		= String.Format("{0:c}", dataView1[0]["RetailPrice"]);
					txtLaborHours.Text	= dataView1[0]["LabourHours"].ToString();
				}
				else
				{
					lblNoProducts.Visible = true;
				}
			
			}
			catch( DataException dataExp)
			{
				throw dataExp;
			}
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.dataView1 = new System.Data.DataView();
			this.txtProductID = new System.Windows.Forms.TextBox();
			this.lblProductID = new System.Windows.Forms.Label();
			this.lblRangeName = new System.Windows.Forms.Label();
			this.txtRangeName = new System.Windows.Forms.TextBox();
			this.lblDescription = new System.Windows.Forms.Label();
			this.txtDescription = new System.Windows.Forms.TextBox();
			this.lblType = new System.Windows.Forms.Label();
			this.txtType = new System.Windows.Forms.TextBox();
			this.lblCost = new System.Windows.Forms.Label();
			this.txtCost = new System.Windows.Forms.TextBox();
			this.lblWholeSale = new System.Windows.Forms.Label();
			this.txtWholeSale = new System.Windows.Forms.TextBox();
			this.lblRetail = new System.Windows.Forms.Label();
			this.txtRetail = new System.Windows.Forms.TextBox();
			this.LaborHours = new System.Windows.Forms.Label();
			this.txtLaborHours = new System.Windows.Forms.TextBox();
			this.lblNoProducts = new System.Windows.Forms.Label();
			this.timer1 = new System.Timers.Timer();
			this.picShape = new System.Windows.Forms.PictureBox();
			((System.ComponentModel.ISupportInitialize)(this.dataView1)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.timer1)).BeginInit();
			this.SuspendLayout();
			// 
			// dataView1
			// 
			this.dataView1.AllowDelete = false;
			this.dataView1.AllowEdit = false;
			this.dataView1.AllowNew = false;
			// 
			// txtProductID
			// 
			this.txtProductID.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.txtProductID.Location = new System.Drawing.Point(152, 24);
			this.txtProductID.Name = "txtProductID";
			this.txtProductID.ReadOnly = true;
			this.txtProductID.Size = new System.Drawing.Size(40, 29);
			this.txtProductID.TabIndex = 0;
			this.txtProductID.Text = "";
			// 
			// lblProductID
			// 
			this.lblProductID.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
			this.lblProductID.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.lblProductID.Location = new System.Drawing.Point(16, 24);
			this.lblProductID.Name = "lblProductID";
			this.lblProductID.Size = new System.Drawing.Size(128, 29);
			this.lblProductID.TabIndex = 1;
			this.lblProductID.Text = "Product ID:";
			this.lblProductID.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// lblRangeName
			// 
			this.lblRangeName.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
			this.lblRangeName.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.lblRangeName.Location = new System.Drawing.Point(16, 72);
			this.lblRangeName.Name = "lblRangeName";
			this.lblRangeName.Size = new System.Drawing.Size(128, 29);
			this.lblRangeName.TabIndex = 3;
			this.lblRangeName.Text = "Range Name:";
			this.lblRangeName.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// txtRangeName
			// 
			this.txtRangeName.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.txtRangeName.Location = new System.Drawing.Point(152, 72);
			this.txtRangeName.Name = "txtRangeName";
			this.txtRangeName.ReadOnly = true;
			this.txtRangeName.Size = new System.Drawing.Size(232, 29);
			this.txtRangeName.TabIndex = 2;
			this.txtRangeName.Text = "";
			// 
			// lblDescription
			// 
			this.lblDescription.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
			this.lblDescription.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.lblDescription.Location = new System.Drawing.Point(16, 120);
			this.lblDescription.Name = "lblDescription";
			this.lblDescription.Size = new System.Drawing.Size(128, 29);
			this.lblDescription.TabIndex = 5;
			this.lblDescription.Text = "Description:";
			this.lblDescription.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// txtDescription
			// 
			this.txtDescription.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.txtDescription.Location = new System.Drawing.Point(152, 120);
			this.txtDescription.Name = "txtDescription";
			this.txtDescription.ReadOnly = true;
			this.txtDescription.Size = new System.Drawing.Size(232, 29);
			this.txtDescription.TabIndex = 4;
			this.txtDescription.Text = "";
			// 
			// lblType
			// 
			this.lblType.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
			this.lblType.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.lblType.Location = new System.Drawing.Point(16, 160);
			this.lblType.Name = "lblType";
			this.lblType.Size = new System.Drawing.Size(128, 29);
			this.lblType.TabIndex = 7;
			this.lblType.Text = "Type:";
			this.lblType.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// txtType
			// 
			this.txtType.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.txtType.Location = new System.Drawing.Point(152, 160);
			this.txtType.Name = "txtType";
			this.txtType.ReadOnly = true;
			this.txtType.Size = new System.Drawing.Size(232, 29);
			this.txtType.TabIndex = 6;
			this.txtType.Text = "";
			// 
			// lblCost
			// 
			this.lblCost.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
			this.lblCost.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.lblCost.Location = new System.Drawing.Point(16, 200);
			this.lblCost.Name = "lblCost";
			this.lblCost.Size = new System.Drawing.Size(128, 29);
			this.lblCost.TabIndex = 9;
			this.lblCost.Text = "Cost:";
			this.lblCost.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// txtCost
			// 
			this.txtCost.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.txtCost.Location = new System.Drawing.Point(152, 200);
			this.txtCost.Name = "txtCost";
			this.txtCost.ReadOnly = true;
			this.txtCost.Size = new System.Drawing.Size(232, 29);
			this.txtCost.TabIndex = 8;
			this.txtCost.Text = "";
			// 
			// lblWholeSale
			// 
			this.lblWholeSale.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
			this.lblWholeSale.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.lblWholeSale.Location = new System.Drawing.Point(16, 248);
			this.lblWholeSale.Name = "lblWholeSale";
			this.lblWholeSale.Size = new System.Drawing.Size(128, 29);
			this.lblWholeSale.TabIndex = 11;
			this.lblWholeSale.Text = "WholeSale:";
			this.lblWholeSale.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// txtWholeSale
			// 
			this.txtWholeSale.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.txtWholeSale.Location = new System.Drawing.Point(152, 248);
			this.txtWholeSale.Name = "txtWholeSale";
			this.txtWholeSale.ReadOnly = true;
			this.txtWholeSale.Size = new System.Drawing.Size(232, 29);
			this.txtWholeSale.TabIndex = 10;
			this.txtWholeSale.Text = "";
			// 
			// lblRetail
			// 
			this.lblRetail.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
			this.lblRetail.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.lblRetail.Location = new System.Drawing.Point(16, 288);
			this.lblRetail.Name = "lblRetail";
			this.lblRetail.Size = new System.Drawing.Size(128, 29);
			this.lblRetail.TabIndex = 13;
			this.lblRetail.Text = "Retail:";
			this.lblRetail.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// txtRetail
			// 
			this.txtRetail.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.txtRetail.Location = new System.Drawing.Point(152, 288);
			this.txtRetail.Name = "txtRetail";
			this.txtRetail.ReadOnly = true;
			this.txtRetail.Size = new System.Drawing.Size(232, 29);
			this.txtRetail.TabIndex = 12;
			this.txtRetail.Text = "";
			// 
			// LaborHours
			// 
			this.LaborHours.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
			this.LaborHours.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.LaborHours.Location = new System.Drawing.Point(16, 328);
			this.LaborHours.Name = "LaborHours";
			this.LaborHours.Size = new System.Drawing.Size(128, 29);
			this.LaborHours.TabIndex = 15;
			this.LaborHours.Text = "Labor Hours:";
			this.LaborHours.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// txtLaborHours
			// 
			this.txtLaborHours.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.txtLaborHours.Location = new System.Drawing.Point(152, 328);
			this.txtLaborHours.Name = "txtLaborHours";
			this.txtLaborHours.ReadOnly = true;
			this.txtLaborHours.Size = new System.Drawing.Size(232, 29);
			this.txtLaborHours.TabIndex = 14;
			this.txtLaborHours.Text = "";
			// 
			// lblNoProducts
			// 
			this.lblNoProducts.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.lblNoProducts.Location = new System.Drawing.Point(200, 24);
			this.lblNoProducts.Name = "lblNoProducts";
			this.lblNoProducts.Size = new System.Drawing.Size(176, 24);
			this.lblNoProducts.TabIndex = 16;
			this.lblNoProducts.Text = "No Products Found";
			this.lblNoProducts.Visible = false;
			// 
			// timer1
			// 
			this.timer1.Enabled = true;
			this.timer1.SynchronizingObject = this;
			// 
			// picShape
			// 
			this.picShape.Location = new System.Drawing.Point(408, 16);
			this.picShape.Name = "picShape";
			this.picShape.Size = new System.Drawing.Size(168, 336);
			this.picShape.TabIndex = 17;
			this.picShape.TabStop = false;
			// 
			// FrmProductDetail
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(164)), ((System.Byte)(198)), ((System.Byte)(249)));
			this.ClientSize = new System.Drawing.Size(592, 566);
			this.Controls.Add(this.picShape);
			this.Controls.Add(this.lblNoProducts);
			this.Controls.Add(this.LaborHours);
			this.Controls.Add(this.txtLaborHours);
			this.Controls.Add(this.lblRetail);
			this.Controls.Add(this.txtRetail);
			this.Controls.Add(this.lblWholeSale);
			this.Controls.Add(this.txtWholeSale);
			this.Controls.Add(this.lblCost);
			this.Controls.Add(this.txtCost);
			this.Controls.Add(this.lblType);
			this.Controls.Add(this.txtType);
			this.Controls.Add(this.lblDescription);
			this.Controls.Add(this.txtDescription);
			this.Controls.Add(this.lblRangeName);
			this.Controls.Add(this.txtRangeName);
			this.Controls.Add(this.lblProductID);
			this.Controls.Add(this.txtProductID);
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "FrmProductDetail";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
			this.Text = "Product Detail";
			this.Closing += new System.ComponentModel.CancelEventHandler(this.FrmProductDetail_Closing);
			((System.ComponentModel.ISupportInitialize)(this.dataView1)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.timer1)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		private void FrmProductDetail_Closing(object sender, System.ComponentModel.CancelEventArgs e)
		{
			this.Dispose();
		}
	}
}